package pers.cyril.jdb.client.command;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import lombok.Data;
import pers.cyril.jdb.client.command.validator.NullParameterValidator;


/**
 * 连接服务器命令
 *
 * @author Wang Cyril
 * @date 2024/5/20 12:50
 */
@Parameters(commandNames="connect",commandDescription = "connect to jdb server")
@Data
public class ConnectCommand {

    public static class HostValidator extends NullParameterValidator {

        public HostValidator() {
            super("pls input valid host, usage -h or --host");
        }

    }

    public static class PortValidator extends NullParameterValidator {

        public PortValidator() {
            super("pls input valid port, usage -p or --port");
        }
    }

    @Parameter(names = {"-h", "--host"}, description = "Connection host", validateWith = HostValidator.class)
    private String host;

    @Parameter(names = {"-p", "--port"}, description = "Connection port", validateWith = PortValidator.class)
    private Integer port;

    @Parameter(names = {"-u", "--username"}, description = "Connection username")
    private String username;

    @Parameter(names = {"-pw", "--password"}, description = "Connection password")
    private String password;
}
